public class 比较版本号 {
    public int compareVersion(String version1, String version2) {
        String[] versions1 = version1.split("\\.");
        String[] versions2 = version2.split("\\.");
        int n = versions1.length;
        int m = versions2.length;
        int i = 0;
        for(;i < Math.min(n,m);i++) {
            int a = Integer.parseInt(versions1[i]);
            int b = Integer.parseInt(versions2[i]);

            if (a < b) {
                return -1;
            } else if(a > b) {
                return 1;
            } else {
                continue;
            }
        }
        while (i < n) {
            int a = Integer.parseInt(versions1[i++]);
            if (a > 0) {
                return 1;
            } else {
                continue;
            }
        }
        while (i < m) {
            int a = Integer.parseInt(versions2[i++]);
            if (a > 0) {
                return -1;
            } else {
                continue;
            }
        }
        return 0;
    }
}
